<?php if (!defined("_ECRIRE_INC_VERSION")) return;
/**
 * EcataloguE
 *
 * @author     Aleksey Yaroshchuk (aleksey.yaroshchuk@gmail.com)
 * @license    GNU/GPL
 * @package    plugins
 * @subpackage ecatalogue
 * @copyright  (c) Aleksey Yaroshchuk 2011-2012
 * @link       http://www.spip-contrib.net/EcataloguE
 */
 
   function ecatalogue_affiche_milieu($flux) {
	$exec =  $flux['args']['exec'];
	
	// Attach to articles
	if ($exec=='articles' AND $id_article = $flux['args']['id_article']) {
		//$id_article = $flux['args']['id_article'];
		if (!$id_rubrique = $flux['args']['id_rubrique']) {
			$id_rubrique = sql_getfetsel('id_rubrique', 'spip_articles', 'id_article='. $id_article);
		}
        include_spip('classes/class.Ecatalogue');
        $catalogue = new Ecatalogue();
		if ($catalogue->IsEcatalogueRubrique($id_rubrique)) {			
			$contexte = $_GET;
			$flux['data'] .= recuperer_fond('prive/box/ecatalogue_article', $contexte, array('ajax'=>true));
		}
	}
    
    // Attach to rubriques
	if ($exec=='naviguer' AND $id_rubrique = $flux['args']['id_rubrique']) {        
        include_spip('classes/class.Ecatalogue');
        $catalogue = new Ecatalogue();
		if ($catalogue->IsEcatalogueRubrique($id_rubrique)) {			
			$contexte = $_GET;
			$flux['data'] .= recuperer_fond('prive/box/ecatalogue_rubrique', $contexte, array('ajax'=>true));
		}
	}

	return $flux;
}
?>